import Vue from "vue";
import Vuex from "vuex";
import getters from '../store/getters';
import mutations from '../store/mutations';
import actions from '../store/actions';
Vue.use(Vuex);

//全局状态管理，相当于一个公共变量，并且是响应式的，任何一个组件更改其内容，可以响应式更新页面

// const moduleA = {
//   state: {
//   name:"dddd"
// },
//   getters: {},
//   actions: {},
//   mutations:{}
// }

export default new Vuex.Store({

  state: {
    isLogin: window.localStorage.getItem('isLogin' || '[]') == null ? '' : true,
    user: {
      user_name: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).user_name,
      user_id: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).user_id,
      following_list: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).following_list,
      following_num: window.localStorage.getItem('user' || '[]') == null ? 0 : JSON.parse(window.localStorage.getItem('user' || '[]')).following_num,
      fan_num: window.localStorage.getItem('user' || '[]') == null ? 0 : JSON.parse(window.localStorage.getItem('user' || '[]')).fan_num,
      fans_list: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).fans_list,
      user_img: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).user_img,
      user_age: window.localStorage.getItem('user' || '[]') == null ? 0 : JSON.parse(window.localStorage.getItem('user' || '[]')).user_age,
      user_sex: window.localStorage.getItem('user' || '[]') == null ? 0 : JSON.parse(window.localStorage.getItem('user' || '[]')).user_sex,
      user_pro: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).user_pro,
      collection_list: window.localStorage.getItem('user' || '[]') == null ? '' : JSON.parse(window.localStorage.getItem('user' || '[]')).collection_list,
      is_manager: window.localStorage.getItem('user' || '[]') == null ? 0 : JSON.parse(window.localStorage.getItem('user' || '[]')).is_manager
    },
    info: [
      {
        theme_post: {
          theme_post_id: '',
          theme_post_title: '',
          theme_post_content: '',
          user_id: 0,
          theme_post_createTime: '',
          is_fine: 0,
          is_top: 0,
          theme_post_lock:0
        },
        user: {
          user_id: 0,
          user_name: '',
          user_password: '',
          user_img:'',
          user_age:0,
          user_sex: 0,
          user_pro: '',
          user_hobby: '',
          following_list: '',
          following_num: 0,
          fan_num: 0,
          fans_list: '',
          user_pro: '',
          collection_list: '',
          user_lock: '',
          is_manager:0,
        }
      }
    ],
    totalElements: 16,
    registeruser: '',

  },
  mutations,
  actions,
  modules: {},
  getters
});
